package top.jlzhou.jobs.controller;


import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import top.jlzhou.R;
import top.jlzhou.jobs.entity.Outgoing;
import top.jlzhou.jobs.service.OutgoingService;
import top.jlzhou.jobs.vo.OutgoingPage;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;

/**
 * <p>
 *  前端控制器
 * </p>
 *
 * @author J.L.Zhou
 * @since 2018-10-22
 */
@Controller
@RequestMapping("/outgoing")
public class OutgoingController {

	@Autowired
	private OutgoingService service;
	
	@RequestMapping("add")
	@ResponseBody
	public R doAdd(Long token,Outgoing outgoing) {
		try {
			service.add(token,outgoing);
			return R.ok();
		}catch (Exception e) {
			return R.error(e.getMessage());
		}
	}
	
	@RequestMapping("page")
	@ResponseBody
	public R doPage(OutgoingPage page){
		try {
			return R.ok().put("page", service.page(page));
		}catch (Exception e) {
			return R.error(e.getMessage());
		}
	}
	
	@RequestMapping("delete")
	@ResponseBody
	public R doDelete(Long token,Long id) {
		try {
			service.delete(token, id);
			return R.ok();
		}catch (Exception e) {
			return R.error(e.getMessage());
		}
	}
	
}

